package com.douglas.managesystem.service.system.impl;

import com.douglas.managesystem.common.SearchEntity;
import com.douglas.managesystem.dao.system.SysLoggerMapper;
import com.douglas.managesystem.entity.system.SysLogger;
import com.douglas.managesystem.service.system.SysLoggerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description TODO
 * @Author 以梦为馬 <Douglas1314@126.com>
 * @Version V1.0.0
 * @Date 2020-11-19 0:00
 **/
@SuppressWarnings("all")
@Service
public class SysLoggerServiceImpl implements SysLoggerService {

    @Autowired
    private SysLoggerMapper sysLoggerMapper;


    /**
     * 1.记录日志
     * @param sysLogger
     */
    @Override
    public void insert(SysLogger sysLogger) {
        sysLoggerMapper.insert(sysLogger);
    }

    /**
     * 2.分页查询日志
     * @param params
     * @return
     */
    @Override
    public PageInfo<SysLogger> queryListByPage(SearchEntity params) {
        if(params.getPageNum() == null || params.getPageNum() == 0) {
            params.setPageNum(1);
        }
        if(params.getPageSize() == null || params.getPageSize() == 0) {
            params.setPageSize(10);
        }
        PageHelper.startPage(params.getPageNum(), params.getPageSize());
        List<SysLogger> list = sysLoggerMapper.queryListByPage(params.getEntity());
        PageInfo<SysLogger> page = new PageInfo<SysLogger>(list);
        return page;
    }
}
